<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of login
 * 
 * @author Subha Sundar Das (subhasundar.das@gmail.com)
 */
class Login extends MY_Controller {

    //put your code here

    function login() {
        parent :: __construct();
        $this->load->model('pickup_model');
        $this->load->model('location_model');
        $this->load->model('member_model');
        $this->load->model('management_model');   
    }
//--Subha (28/08/2012)--/
    function index() {
        $this->template->title('Welcome', 'carz.com')
                ->set_partial('header', 'header/header')
                ->set_partial('footer', 'footer/footer')
                ->set_partial('login', 'boxes/login')
                ->set_partial('featured', 'boxes/featured')
                ->set_partial('customer_care', 'sidebar/customer_care')
                ->set_partial('social_share', 'sidebar/social_share')
                ->set_partial('search_reviews', 'sidebar/search_reviews')
                ->set_partial('recent_news', 'sidebar/recent_news')
                ->set_partial('recent_reviews', 'sidebar/recent_reviews')
                ->set_partial('dealer', 'dealer/dealer')
                ->build('pages/index');
       
    }

//--Subha (28/08/2012)--/    
    function submit() {
        $this->form_validation->set_rules('login_email', 'Login Email', 'trim|required|valid_email');
        $this->form_validation->set_rules('login_password', 'Password', 'trim|required|min_length[4]');
        if ($this->form_validation->run() == FALSE) {
            $msg = "Invalid Login, Try again ..";
            $this->session->set_flashdata('message', $msg);
            redirect('member/login');
        } else {
            $post_data = array(
                'email' => $_POST['login_email'],
                'password' => $_POST['login_password']);
            $msg = $this->member_model->check_member($post_data);
            if (isset($msg)) {
                $this->session->set_flashdata('message', $msg);
                redirect('member/login');
            } else {
                redirect('member/myaccount/');
            }
        }
    }

    
    
    
    
}

?>
